<template>
    <j-modal
            :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
            :title="title"
            :visible="visible"
            :width="width"
            cancelText="关闭"
            switchFullscreen
            @cancel="handleCancel"
            @ok="handleOk">
        <authorization-info-form ref="realForm" :disabled="disableSubmit"
                                 @ok="submitCallback"></authorization-info-form>
    </j-modal>
</template>

<script>

import AuthorizationInfoForm from './AuthorizationInfoForm'

export default {
    name: 'AuthorizationInfoModal',
    components: {
        AuthorizationInfoForm
    },
    data() {
        return {
            title: '',
            width: 800,
            visible: false,
            disableSubmit: false
        }
    },
    methods: {
        add() {
            this.visible = true
            this.$nextTick(() => {
                this.$refs.realForm.add();
            })
        },
        edit(record) {
            this.visible = true
            this.$nextTick(() => {
                this.$refs.realForm.edit(record);
            })
        },
        close() {
            this.$emit('close');
            this.visible = false;
        },
        handleOk() {
            this.$refs.realForm.submitForm();
        },
        submitCallback() {
            this.$emit('ok');
            this.visible = false;
        },
        handleCancel() {
            this.close()
        }
    }
}
</script>